package com.alstudio.utils.android.notification;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.BitmapFactory;

import com.alstudio.R;
import com.alstudio.ui.base.BaseActivity;
import com.alstudio.utils.android.AndroidUtils;

public class ALNotificationManager {

	public static NotificationManager getAndroidNotificationManager(
			Context context) {
		NotificationManager manager = (NotificationManager) context
				.getSystemService(Context.NOTIFICATION_SERVICE);
		return manager;
	}

	public static void showNotification(Context context,
			ALNotification notification) {
		getAndroidNotificationManager(context).notify(notification.getId(),
				notification.build());
	}

	public static void cancelNotification(Context context,
			ALNotification notification) {
		getAndroidNotificationManager(context).cancel(notification.getId());
	}

	public static ALNotification showNotification(BaseActivity context,
			boolean old) {
		{
			ALNotification builder = new ALNotification(
					context,
					com.alstudio.utils.android.notification.ALNotification.ALNotificationType.AL_NOTIFICATION_TYPE_PROGRESS,
					"准备开始下载了");
			builder.setAutoCancel(true);
			builder.setContentTitle("新通知方法测试标题");
			builder.setContentText("这事新同志方法测试");
			builder.setContentInfo("这个我也不知道说什么好 ");
			builder.setSmallIcon(R.drawable.bar_icon_back);
			builder.setLargeIcon(BitmapFactory.decodeResource(
					context.getResources(), R.drawable.bar_icon_back));
			builder.setId(10086);

			builder.setNumber(10);
			builder.setContentIntent(ALNotification.backToApp(context));
			 builder.setProgress(100, 0, false);

			getAndroidNotificationManager(context).notify(builder.getId(), builder.build());

			return builder;
		}
	}

	// public static ALNontification showALNotification(BaseActivity context) {
	// ALNontification n = new ALNontification(context, "这个是时间",
	// ALNotificationType.AL_NOTIFICATION_TYPE_PROGRESS);
	//
	// n.setAutoCancel(true);
	// n.setContentTitle("测试测试");
	// n.setContentText("我在测试新方法");
	// n.setWhen(System.currentTimeMillis());
	// n.setSmallIcon(R.drawable.login_bt_on);
	// n.setContentIntent(n.backToApp(context));
	// n.setId(10086);
	// n.setDefaults(Notification.DEFAULT_ALL);
	//
	// RemoteViews v = new RemoteViews(context.getApplication()
	// .getPackageName(), R.layout.progress_notification_layout);
	// n.setTicker("这个是时间？", v);
	// n.setContent(v);
	// n.setProgress(100, 50, false);
	//
	// n.setShowing(true);
	//
	// n = ALNotificationBuilder.build(n);
	// getAndroidNotificationManager(context).notify(n.getId(),
	// n.mNotification);
	//
	// return n;
	// }

	// public static void showProgress(final BaseActivity context) {
	// final NotificationCompat.Builder mBuilder = new
	// NotificationCompat.Builder(
	// context);
	// mBuilder.setContentTitle("Picture Download")
	// .setContentText("Download in progress")
	// .setSmallIcon(R.drawable.login_bt_on);
	// mBuilder.setContentIntent(ALNontification.backToApp(context));
	// // Start a lengthy operation in a background thread
	// new Thread(new Runnable() {
	// @Override
	// public void run() {
	// int incr;
	// // Do the "lengthy" operation 20 times
	// for (incr = 0; incr <= 100; incr += 5) {
	// // Sets the progress indicator to a max value, the
	// // current completion percentage, and "determinate"
	// // state
	// mBuilder.setProgress(100, incr, false);
	// // Displays the progress bar for the first time.
	// getAndroidNotificationManager(context).notify(0,
	// mBuilder.build());
	// // Sleeps the thread, simulating an operation
	// // that takes time
	// try {
	// // Sleep for 5 seconds
	// Thread.sleep(5 * 1000);
	// } catch (InterruptedException e) {
	// }
	// }
	// // When the loop is finished, updates the notification
	// mBuilder.setContentText("Download complete")
	// // Removes the progress bar
	// .setProgress(0, 0, false);
	// getAndroidNotificationManager(context).notify(0,
	// mBuilder.build());
	// }
	// }
	// // Starts the thread by calling the run() method in its Runnable
	// ).start();
	// }

}
